Public Class ComputerInfoForm

  Private Sub ComputerInfoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComputerInfoButton.Click
    Me.OutputTextBox.Clear()

    Dim info As dotNetTips.Utility.ComputerInfo = dotNetTips.Utility.ComputerHelper.ComputerInformation

    Dim sb As New System.Text.StringBuilder(100)

    sb.AppendFormat("UI Culture: {0}", info.InstalledUICulture)
    sb.AppendLine()
    sb.AppendFormat("OS Full Name: {0}", info.OSFullName)
    sb.AppendLine()
    sb.AppendFormat("OS Platform: {0}", info.OSPlatform)
    sb.AppendLine()
    sb.AppendFormat("OS Version: {0}", info.OSVersion)
    sb.AppendLine()

    Me.OutputTextBox.Text = sb.ToString

  End Sub

  Private Sub ComputerDirsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComputerDirsButton.Click

    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder

    For Each dir As String In dotNetTips.Utility.IO.DirectoryHelper.Directories("c:\")
      sb.AppendLine(dir.ToString)
    Next

    Me.OutputTextBox.Text = sb.ToString

  End Sub

  Private Sub DirFilesButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirFilesButton.Click
    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder

    For Each file As String In dotNetTips.Utility.IO.DirectoryHelper.DirectoryFiles("c:\", FileIO.SearchOption.SearchTopLevelOnly)
      sb.AppendLine(file.ToString)
    Next

    Me.OutputTextBox.Text = sb.ToString

  End Sub

  Private Sub DirFilesInfoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirFilesInfoButton.Click
    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder

    For Each file As dotNetTips.Utility.FileInformation In dotNetTips.Utility.IO.DirectoryHelper.DirectoryFilesInformation("c:\", FileIO.SearchOption.SearchTopLevelOnly)
      sb.AppendFormat("{0} Length:{1} Read-Only:{2}", file.FullName, file.Length, file.IsReadOnly)
      sb.AppendLine()
    Next

    Me.OutputTextBox.Text = sb.ToString

  End Sub

  Private Sub DrivesButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrivesButton.Click
    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder

    For Each drive As System.IO.DriveInfo In dotNetTips.Utility.ComputerHelper.ComputerReadyDrives()
      sb.AppendFormat("{0}  Ready:{1} Label:{2}", drive.Name, drive.IsReady, drive.VolumeLabel)
      sb.AppendLine()
    Next

    Me.OutputTextBox.Text = sb.ToString

  End Sub

  Private Sub MemoryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MemoryButton.Click
    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder(200)

    Dim memory As dotNetTips.Utility.ComputerMemory = dotNetTips.Utility.ComputerHelper.ComputerMemory

    sb.AppendFormat("Available Physical Memory - {0}", memory.AvailablePhysicalMemory.ToString("###,###,###,###"))
    sb.AppendLine()
    sb.AppendFormat("Available Virtual Memory - {0}", memory.AvailableVirtualMemory.ToString("###,###,###,###"))
    sb.AppendLine()
    sb.AppendFormat("Total Physical Memory - {0}", memory.TotalPhysicalMemory.ToString("###,###,###,###"))
    sb.AppendLine()
    sb.AppendFormat("Total Virtual Memory - {0}", memory.TotalVirtualMemory.ToString("###,###,###,###"))
    sb.AppendLine()

    Me.OutputTextBox.Text = sb.ToString
  End Sub

  Private Sub SoftwareButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoftwareButton.Click
    Me.OutputTextBox.Clear()

    Dim sb As New System.Text.StringBuilder

    For Each product As dotNetTips.Utility.InstalledProduct In dotNetTips.Utility.ComputerHelper.ServerInstalledSoftware(".")
      sb.AppendFormat("{0}  Installed:{1}", product.Description, product.InstallDate.ToShortDateString)
      sb.AppendLine()
    Next

    Me.OutputTextBox.Text = sb.ToString

  End Sub
End Class